package com.zr.domain.sp.controller.zk;

import com.zr.domain.sp.tool.zk.WatcherApi;
import com.zr.domain.sp.tool.zk.utils.ZkApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class HelloWorldController {
    @Autowired
    private ZkApi zkApi;

    @Autowired
    WatcherApi watcherApi;

    @GetMapping(value = "createNode")
    public boolean createNode(String path, String data) {
        log.debug("ZookeeperController create node {},{}", path, data);
        return  zkApi.createNode(path, data);
    }


    @GetMapping(value = "getNode")
    public String getNode(String path, String data) {
        log.debug("ZookeeperController create node {},{}", path, data);
     return zkApi.getData(path, watcherApi);
    }


}
